﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title>Matrix Admin</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="~/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/bootstrap-responsive.min.css" />
<link rel="stylesheet" href="~/css/colorpicker.css" />
<link rel="stylesheet" href="~/css/datepicker.css" />
<link rel="stylesheet" href="~/css/uniform.css" />
<link rel="stylesheet" href="~/css/select2.css" />
<link rel="stylesheet" href="~/css/matrix-style2.css" />
<link rel="stylesheet" href="~/css/matrix-media.css" />
<link rel="stylesheet" href="~/css/bootstrap-wysihtml5.css" />

<style>
	.control-group .controls label{
		display:inline-block;
	}
</style>
</head>
<body>

<div id="content">
  <div id="content-header">
      <h1>修改密码</h1>
  </div>
<div class="container-fluid">
  <div class="row-fluid">
    <div class="span6">
      <div class="widget-box">
        <div class="widget-title"> <span class="icon"> <i class="icon-align-justify"></i> </span>
          <h5>修改密码</h5>
        </div>
        <div class="widget-content nopadding">
          <form action="#" id="form" method="get" class="form-horizontal">
            <div class="control-group">
              <label class="control-label">原密码 :</label>
              <div class="controls">
                <input type="password" id="oldPassword" name="oldPassword" class="span11"  />
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">新密码 :</label>
              <div class="controls">
                <input type="password" class="span11" id="newPassword" name="newPassword" />
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">确认密码</label>
              <div class="controls">
                <input type="password"  class="span11" id="confirmPassword" name="confirmNewPassword"  />
                <div id="confirmPasswordTip" style="display:none">新密码与确认密码不一致！</div>
              </div>
            </div>
            <div class="form-actions">
              <button type="button" onclick="save(this)" class="btn btn-success">Save</button>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div></div>

    <!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" data-backdrop="static" data-keyboard="false" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h3 class="modal-title" id="myModalLabel">
                    提示信息
				</h3>
			</div>
			<div class="modal-body">
                <p></p>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal" id="modelClose">关闭
				</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->

    </div>
<script src="~/js/jquery.min.js"></script> 
<script src="~/js/bootstrap.min.js"></script> 
<script type="text/javascript">

    function save(obj) {
        var reg = /[!@@#$%^&*()-=]{1,}/g;
        var old = $("#oldPassword").val();
        var newPassword = $("#newPassword").val();
        var confirmPassword = $("#confirmPassword").val();
        if (old == "" || newPassword == "" || confirmPassword == "") {
            alert('必须填写原始密码,新密码和确认密码！');
            return;
        }
        //if (!reg.test(newPassword)) {
        //    alert('新密码必须包含特殊字符：!@@#$%^&*()-= 其中之一！');
        //    return;
        //}
        if (newPassword != confirmPassword) {
            $("#confirmPasswordTip").show();
            return;
        } else {
            $("#confirmPasswordTip").hide();
        }
        $.post("/account/changepassword", { oldPassword: old, newPassword: newPassword }, function (msg) {
            if (msg.IsSuccess) {
                alert( '修改密码成功！3秒后退出系统！');
                setTimeout(function () {
                    window.parent.location.href = "/account/logoff";
                }, 3000);
            } else {
               alert( msg.ErrorMessage);
            }
        });
    }


function showDialog(title,msg) {
	$("#myModal").find(".modal-header h3").html(title);
    $("#myModal").find(".modal-body p").html(msg);
    $("#myModal").modal('show');
    
    //setTimeout(function(){
    //    $("#myModal").attr('class','modal hide');
    //},4500);
}
</script>
</body>
</html>
